#include <QtOpenGL>
#include "cone.h"
#include <GL/glu.h>

Cone::Cone(const QVector3D& center, QObject *parent):
    Object3D(center, parent)
{

}

GLuint tex;


void Cone::drawGeometry(void)
{
    //glColor3f(0.0,0.0,0.0);
  //  glScalef(0.5, 0.5, 0.5);
    GLUquadric *quad = gluNewQuadric();
   // setEscala(2,2,2);
    //gluQuadricDrawStyle(quad, GLU_FILL);
    //gluQuadricNormals(quad, GLU_SMOOTH);

   // gluQuadricTexture(quad, true);

  //  program.bind();
    //gluSphere(quad, 1, 30, 30);
//        gluQuadricDrawStyle(quad, GLU_FILL); /* flat shaded */
  //     gluQuadricNormals(quad, GLU_FLAT);
      // glNewList(startList+1, GL_COMPILE);

    glEnable(GL_TEXTURE_1D);

   // glGenTextures(1, texture());
    glBindTexture(GL_TEXTURE_1D, texture());
    GLubyte gradient[6] = { 255,0,0, 0,255,0 };
    glTexImage1D(GL_TEXTURE_1D, 0, GL_RGBA8, 2, 0, GL_RGB, GL_UNSIGNED_BYTE, gradient);
    glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
    glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);

    gluQuadricDrawStyle(quad,GLU_FILL);
    gluQuadricTexture(quad,GL_TRUE);
   // gluCylinder(quad,1.0f,1.0f,3.0f,32,32);


    //setTexture(tex);





//    GLfloat texgen_coeff[4] = {1./height, 0., 0., 0.};
//    glEnable(GL_TEXTURE_GEN_S);
//    glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);
//    glTexGenfv(GL_S, GL_OBJECT_PLANE, texgen_coeff);


    gluCylinder(quad,1, 0.0, 1.0, 15, 5);

 //   gluQuadricNormals(quad, GLU_FLAT);
   // gluQuadricDrawStyle(quad, GLU_LINE); /* wireframe */
   // gluQuadricNormals(quad,GLU_)
     //glNormal3f(0.0,0.0,1.0);
      gluQuadricOrientation(quad,GLU_INSIDE);
    gluDisk(quad, 0, 1, 20, 4);




// program.release();


    //glEnd();

}
